package com.huawei.hwCloudJs.service.debugtool;

import android.app.Service;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Binder;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.text.TextUtils;
import android.util.Log;
import com.huawei.hwCloudJs.a.a.a;
import com.huawei.hwCloudJs.d.f;
import com.huawei.hwCloudJs.service.a.b;

public class ConnectionSdkService extends Service {
    private static final String TAG = "ConnectionSdkService";
    a mBinder = new a(this) {
        final /* synthetic */ ConnectionSdkService b;

        {
            this.b = r1;
        }

        public int a(Bundle bundle) throws RemoteException {
            if (bundle == null) {
                return -1;
            }
            Object string = bundle.getString("appId");
            String string2 = bundle.getString("url");
            Object string3 = bundle.getString("pkg");
            if (TextUtils.isEmpty(string) || TextUtils.isEmpty(string2) || TextUtils.isEmpty(string3)) {
                return -1;
            }
            PackageManager packageManager = this.b.getPackageManager();
            if (packageManager == null) {
                return -1;
            }
            String[] packagesForUid = packageManager.getPackagesForUid(Binder.getCallingUid());
            if (packagesForUid == null || packagesForUid.length == 0) {
                return -1;
            }
            String str = "";
            for (String str2 : packagesForUid) {
                if (string3.equals(str2)) {
                    break;
                }
            }
            String str22 = str;
            if (!f.d(this.b.getApplicationContext(), str22)) {
                return -2;
            }
            if (!b.a().a(string, string2, this.b.getApplicationContext())) {
                return -2;
            }
            if (SetUrl.a().b() == null) {
                return -2;
            }
            SetUrl.a().b().OnResult(string2);
            return 0;
        }
    };

    public IBinder onBind(Intent intent) {
        Log.i(TAG, "onBind");
        return this.mBinder;
    }
}
